package com.ewzj.bigdata.mvp.model

import com.ewzj.bigdata.app.config.netmodel.CommonService
import com.ewzj.bigdata.app.extensions.json2Body
import com.ewzj.bigdata.mvp.contract.HourseListContract
import com.ewzj.bigdata.mvp.contract.HourseWebActivityContract
import com.ewzj.bigdata.mvp.model.reqbean.ReqPraise
import com.ewzj.bigdata.mvp.model.reqbean.ReqScan
import com.ewzj.bigdata.mvp.model.reqbean.Reqcomentbean
import com.ewzj.bigdata.mvp.model.rspbean.BaseData
import com.ewzj.bigdata.mvp.model.rspbean.CommentBean
import com.google.gson.Gson
import com.jess.arms.integration.IRepositoryManager
import com.jess.arms.mvp.BaseModel
import io.reactivex.Observable
import javax.inject.Inject

/**
 * author:zhangjing
 * 作用:
 * return:
 */
class HourseWebModel @Inject constructor(val mGson : Gson, iRepositoryManager: IRepositoryManager) :BaseModel(iRepositoryManager),HourseWebActivityContract.Model{
    override fun docomment(reqcomentbean: Reqcomentbean): Observable<BaseData<CommentBean>> {
        return service.doComment(json2Body(mGson.toJson(reqcomentbean)))
    }

    val service=iRepositoryManager.obtainRetrofitService(CommonService::class.java)

    override fun doPraise(reqPraise: ReqPraise): Observable<BaseData<String>> {
       return service.doPraise(json2Body(mGson.toJson(reqPraise)))
    }


    override fun read(gourl:String): Observable<BaseData<Any>> {
        val reqScan = ReqScan()
        reqScan.setGo_url(gourl)
        return service.ScanRecV3(json2Body(mGson.toJson(reqScan)))
    }
}